package day11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class SteamTest {
    public static void main(String[] args) {
      // method1();
       // method2();
        //method3();


    }

    private static void method3() {
        int[] arr={1,2,3,45,6};
        Arrays.stream(arr).forEach((s)->{
            System.out.println(s);
        });
    }

    private static void method2() {
        HashMap<String,String> map=new HashMap<>();
        map.put("liuxia","12");
        map.put("beihua","13");
        map.put("shazhu","14");
        map.put("sharen","17");
        map.put("airen","17");
        map.entrySet().stream().limit(2).forEach((s)->
            System.out.println(s)

        );
        System.out.println("=============");
        map.entrySet().stream().skip(2).forEach((s)->
            System.out.println(s));



    }

    private static void method1() {
        ArrayList<String> list=new ArrayList<>();
        list.add(0,"lihua");
        list.add(1,"liuhua");
        list.add(2,"tihua");
        list.add(3,"sahua");
        list.add(4,"tihua");
        list.stream().filter(s -> s.startsWith("li")).forEach(s -> System.out.println(s));
        System.out.println("=============");

        list.stream().distinct().forEach((s)->
                System.out.println(s));
    }
}
